home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
bbs_soft
/
mrun210.zip
/
MRUN210.H
< prev
next >
Wrap
Text File
|
1993-04-28
|
95KB
|
4,068 lines
;MailRun v2.10: Header File
;1992-1993 Gerald P. Sully, all rights reserved.
#comment
**************************************************************************
**************************************************************************
*
* This header file contains routines that are used in various
* places throughout the MailRun source files. It also contains
* global variable definitions and macros.
*
* #ifdef commands have been used to exclude procedures and global
* variables from being compiled in any script module where they
* are not needed. In theory, it should not be necessary to do
* this: Datastorm's documentation says that any procedure or
* variable that isn't used is ignored. In practice, however, the
* compiler will use up its limited memory resources allocating
* space to variables and procedures that never make their way into
* the compiled script.
*
* The following procedures/functions are found in this file
* (roughly in order of appearance):
*
* makefullname(), makemrn(), makebbslist(), maketasklist(),
* makemailrunlist(), makedesc(), gettaskstring(), loadsettings(),
* loadbbsinfo(), loadprompts(), loadmaildoor(), writesettings(),
* writebbsinfo(), writeprompts(), writemaildoor(), openfile(),
* readbbs(), readitem(), writebbs(), writeitem(), getbbscoord(),
* getitemcoord(), getbbsi(), getitemi(), getfirstitem(), copymrn(),
* fverify(), cleardir(), clearfiledesc(), insertitem(), insertbbs(),
* changemailrun(), checkpending(), checkperm(), checkchild(),
* checkrunning(), checkchanged(), checkfile(), checktask(), checknew(),
* menudim(), sortidx(), fieldcompare(), findstring(), interfaceon(),
* interfaceoff(), parsedialog(), swapbbs(), swapitem(), changestatus(),
* taskfilefwd(), taskfileend(), parsemenu(), parseobject(),
* filenewmrun(), filesave(), filesaveas(), filereset(), filedelmrun(),
* fileautorun(), fileexit(), editcut(), editcopy(), editpaste(),
* editdelete(), cfgmrun(), cfgbbs(), cfgprompts(), cfgmaildoor(),
* configbbs(), configmrun(), configprompts(), configmaildoor(),
* defaultsmailrun(), defaultsbbs(), defaultsprompts(), defaultsdoor(),
* addnewbbs(), addgetsend(), addupload(), adddownload(), addsendcmd(),
* addscript(), executemailrun(), executeqwkreader(), executearchiver(),
* executelogviewer(), helpcontents(), helpcontext(), helpabout(),
* callscript()
*
**************************************************************************
**************************************************************************
#endcomment
;Open file indexes
#define IniFile 0
#define MailRunFile 1
#define BBSFile 0
#define TaskFile 1
#define OldTaskFile 2
#define BBSidxFile 0
#define BBSdbfFile 1
#define NewFilesFile 2
#define MRUnarcFile 3
#define OldidxFile 4
#define OlddbfFile 5
#define ScriptFile 0
#define QueueListFile 5
#define OldUBFFile 0
#define OldUDXFile 1
#define MRunUBFFile 2
#define MRunUDXFile 3
#define FileDescFile 4
#define SourceFile 5
;Flags
#define ALLFLAGS 255 ; 2^8 - 1
#define RUNNING 1 ; 2^0
#define CHANGED 2 ; 2^1
#define NEW 4 ; 2^2
#define AGM 8 ; 2^3
#define CMD 16 ; 2^4
#define SCR 32 ; 2^5
#define ABT 64 ; 2^6
#define USR 8 ; 2^3
#define PRMPT 16 ; 2^4
#define QMD 32 ; 2^5
#define DEFAULTS 128 ; 2^7
#define IDLE (ALLFLAGS - RUNNING)
#define UNCHANGED (ALLFLAGS - CHANGED)
#define OLD (ALLFLAGS - NEW)
#define CLEARCMD (ALLFLAGS - AGM - CMD - SCR - ABT)
;System global variables
#define FLAGS i9
#define IdleTimeout i8
#define LogRun i7
#define AppendLog i6
#define AnsiInLog i5
#define NewfileFilter i4
#define GraphicsOn i3
#define HelpPage i2
#define PostRun i1
#define IdleTimer i0
#define TaskItem s9
#define MailRun s8
#define MailRunIni s7
#define TempDir s6
#define MailRunDir s5
#define TaskList s4
#define BBS s3
#define Item s2
#define Conf s1
#define CurrentConf s0
;Macros
#define EscapeFail 0
#define ErrorFail 1
#define ALPHA 0
#define NUMERIC 1
#define MMDDYY 2
#define _READWRITE 0
#define _CREATE 1
#define _TEXT 0
#define _NORMAL 1
;Miscellaneous global variables
string MailRunTrunc
#ifndef MRUN210G
#ifndef MRUN210B
string BBSList
#endif
#ifndef MRUN210F
string BBSType
#endif
#ifndef MRUN210AB
#ifndef MRUN210C
integer PermRadio
#endif
#endif
#endif
#ifdef MRUN210AB
string MailRunList
#endif
#ifdef MRUN210DE
string FileName, FileDesc, FileChoice
#endif
;Global variables containing values displayed in the main dialogbox
#ifdef MRUN210AG
string BBSTotal, BBSComplete, BBSRemaining, AttemptNum
string ItemTotal, ItemComplete, ItemError, ItemRemaining
#endif
;Global variables containing values from [MailRun] section of *.MRN
#ifdef MRUN210AB
string MailDir, ReplyDir, DownloadDir, UploadDir
string DialAttempts, DialTimeout, DialPause
string SavePackets, IdleTime, ExecTime
string Archiver, QWKReader, LogViewer
integer GoWait
#endif
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
;Global variables containing general BBS info from *.MRN
string BBSName, UserName, PWord, XferProt
string CallingFrom, UserResp1, UserResp2
string Number_1, Number_2, Number_3
string LangNumber, MailDoorType
;Global variables containing BBS prompts from MAILRUN.INI
string LangPrompt, GraphicsPrompt, NamePrompt, UserPrompt1
string PWordPrompt, ViewPrompt, FilePrompt, UserPrompt2
string ScanPrompt, MorePrompt, ContinuePrompt, CommandPrompt
string DLPrompt, DLUnavPrompt, ULPrompt, ULDescPrompt
;Global variables containing Mail Door prompts from MAILRUN.INI
string MailPrompt, ReceiveQWKPrompt, MailDLPrompt, MsgMenuPrompt
string MailXferProt, MailULPrompt, QWKArchiver, MailDoor
#endif
#endif
#endif
#comment
*********************************************************************
*
* MAKEFULLNAME()
*
* Called by all modules, various procedures
*
* Appends a filename to a directory name.
*
*********************************************************************
#endcomment
func makefullname : string
strparm Directory, FileNamen
string FullName
FullName = Directory
addfilename FullName FileNamen
return FullName
endfunc
#comment
*********************************************************************
*
* MAKEMRN()
*
* Calls loadsettings(), loadbbsinfo(), loadprompts(), loadmaildoor(),
* writesettings(), writebbsinfo(), writeprompts(), writemaildoor(),
* makefullname(), filesave()
*
* Called by:
* MRUN210A: initialize()
* MRUN210B: newmailrun()
*
* Create the file MAILRUN.MRN and initialize it.
*
*********************************************************************
#endcomment
#ifdef MRUN210AB
proc makemrn
string DLPurgeLimit
#ifndef MRUN210A
string RingInterrupt
#endif
;load the defaults
MailRun = MailRunIni
BBS = "DEFAULT"
loadsettings()
loadbbsinfo()
loadprompts()
loadmaildoor()
profilerd MailRun "MailRun" "DLPurgeLimit" DLPurgeLimit
profilerd MailRun "MailRun" "ExecTime" ExecTime
profilerd MailRun "MailRun" "GoWait" GoWait
profilerd MailRun "MailRun" "PostRun" PostRun
profilerd MailRun "MailRun" "RingInterrupt" RingInterrupt
;write the defaults to the new mailrun
MailRun = makefullname(TempDir, MailRunTrunc)
writesettings()
writebbsinfo()
writeprompts()
writemaildoor()
profilewr MailRun "MailRun" "DLPurgeLimit" DLPurgeLimit
profilewr MailRun "MailRun" "ExecTime" ExecTime
profilewr MailRun "MailRun" "GoWait" GoWait
profilewr MailRun "MailRun" "PostRun" PostRun
profilewr MailRun "MailRun" "RingInterrupt" RingInterrupt
;write the new mailrun to disk
filesave()
endproc
#endif
#comment
*********************************************************************
*
* MAKEBBSLIST()
*
* Calls readbbs()
*
* Called by:
* MRUN210H: editdelete(), editpaste(), callscript()
* MRUN210C: changeuserinfo(), changeprompts(), changemaildoor()
* MRUN210D: main()
* MRUN210E: main()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Creates a list of BBSs for display the BBS combobox of
* various dialog boxes.
*
*********************************************************************
#endcomment
#ifndef MRUN210G
#ifndef MRUN210B
proc makebbslist
string BBSi
integer i
BBSList = ""
i = 1
BBSi = readbbs(i)
while not NULLSTR BBSi
strlwr BBSi
strfmt BBSList "%s,%s" BBSList BBSi
i++
BBSi = readbbs(i)
endwhile
if i > 1
strdelete BBSList 0 1
endif
endproc
#endif
#endif
#comment
*********************************************************************
*
* MAKETASKLIST()
*
* Calls openfile(), gettaskstring(), readbbs(), readitem(),
* makefullname()
*
* Called by:
* MRUN210H: editdelete(), changestatus(), filereset(),
* filedelmrun(), editpaste(), callscript()
* MRUN210A: main(), parsedialog(), swapbbs(), executor()
* MRUN210G: main(), dobbs()
*
*
* Creates the Task List displayed in the main MailRun
* dialog box. Each item of each BBS is read from the *.MRN
* file and a "TaskString" is produced to describe its contents.
* The BBS and Item coordinates are appended to the TaskString
* as an index back into the *.MRN file. Tabstops are used to
* push these indexes beyond the right edge of the Task List
* flistbox so that they are not visible. TaskStrings for BBS
* names have an item coordinate of zero.
*
* Also calculates the values of variables displayed in the
* statistics section of the main dialog box.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc maketasklist
string TaskString, Tasks, Pending
string LastBBS, LastItem, BBSNamen
integer BBST, BBSC, BBSR, ItemT, ItemC, ItemE, ItemR
integer i, j
;set all values displayed in main dialog box to 0
BBST = 0
BBSC = 0
BBSR = 0
ItemT = 0
ItemC = 0
ItemE = 0
Tasks = makefullname(TempDir, "TASKLIST.TMP")
;Save the values for the current BBS and Item
LastItem = Item
LastBBS = BBS
openfile(TaskFile, Tasks, _CREATE, _NORMAL)
i = 1
BBS = readbbs(i)
while not NULLSTR BBS
;Loop through each BBS in the MailRun
ItemR = 0
j = 0
profilerd MailRun BBS "BBSName" BBSNamen
fstrfmt TaskFile "%s`t`t`t%d`t%d`r`n" BBSNamen i j
j++
Item = readitem(j)
while not NULLSTR Item
;Loop through each Item
strextract Pending Item "," 0
if strcmpi Pending "0"
ItemC++
elseif strcmpi Pending "1"
ItemR++
else
ItemE++
endif
TaskString = gettaskstring(i, j)
fstrfmt TaskFile "%s`r`n" TaskString
ItemT++
j++
Item = readitem(j)
endwhile
BBST++
if ItemR == 0
BBSC++
endif
i++
BBS = readbbs(i)
endwhile
fclose TaskFile
Item = LastItem
BBS = LastBBS
;prepare statistics variables for display in the main box
BBSR = BBST - BBSC
ItemR = ItemT - ItemC - ItemE
itoa BBST BBSTotal
itoa BBSC BBSComplete
itoa BBSR BBSRemaining
itoa ItemT ItemTotal
itoa ItemC ItemComplete
itoa ItemE ItemError
itoa ItemR ItemRemaining
endproc
#endif
#comment
*********************************************************************
*
* MAKEMAILRUNLIST()
*
* Calls makefullname()
*
* Called by:
* MRUN210H: filesaveas(), filedelmrun(), callscript()
* MRUN210A: main()
* MRUN210B: main(), newmailrun()
*
* Creates a list of MailRuns for display in the main
* MailRun and MailRun Settings dialog boxes.
*
*********************************************************************
#endcomment
#ifdef MRUN210AB
proc makemailrunlist
string FileTrunc, MRNFile
MailRunList = ""
MRNFile = makefullname(MailRunDir, "*.MRN")
findfirst MRNFile
;Loop through all files in the directory
while FOUND
FileTrunc = $FILENAME
strlwr FileTrunc
strfmt MailRunList "%s,%s" MailRunList FileTrunc
findnext
endwhile
if not NULLSTR MailRunList
strdelete MailRunList 0 1
endif
endproc
#endif
#comment
*********************************************************************
*
* MAKEDESC()
*
* Calls openfile()
*
* Called by:
* MRUN210D: main(), deldlfile()
* MRUN210E: getnewdesc()
*
* Creates the file description for display in the upload
* and download dialog boxes.
*
*********************************************************************
#endcomment
#ifdef MRUN210DE
proc makedesc
strparm DescSource
string DB, DL
integer char
long DescBegin, DescLength, counter
strextract DB FileChoice "`t" 4
atol DB DescBegin
strextract DL FileChoice "`t" 5
atol DL DescLength
if DescLength != 0
;if there is a description in the database, retrieve it
openfile(FileDescFile, FileDesc, _CREATE, _NORMAL)
openfile(SourceFile, DescSource, _READWRITE, _NORMAL)
fseek SourceFile DescBegin 0
for counter = 1 upto DescLength
fgetc SourceFile char
fputc FileDescFile char
endfor
fclose FileDescFile
fclose SourceFile
else
;otherwise, just delete the previous description
openfile(FileDescFile, FileDesc, _CREATE, _NORMAL)
fclose FileDescFile
endif
endproc
#endif
#comment
*********************************************************************
*
* GETTASKSTRING()
*
* Called by:
* MRUN210H: maketasklist(), editdelete(), changestatus(),
* editpaste()
* MRUN210A: parsekeystate(), swapitem()
* MRUN210C: changeuserinfo(), changeprompts(), changemaildoor()
* MRUN210D: main()
* MRUN210E: main()
* MRUN210F: addgetmail(), addsendmail(), adddoscript()
* MRUN210G: dobbs()
*
* Produces a TaskString from the current *.MRN Item.
* Items are strings with the format:
*
* "Pending,Perm,TaskType,FileName,Conf"
*
* Pending = 0 if item is completed, 1 if pending, 2 if an
* error occurred in previous attempt to execute it.
* Perm = 1 if the item is permanent; Perm = 2 if temporary.
* TaskType may be SendMail, GetMail, SendFile, GetFile,
* SendCommand or SendScript.
* FileName is the name of the file to be transferred, used
* by SendFile and GetFile items.
* Conf is the number of the conference to be joined, used
* by SendFile and GetFile items.
*
*********************************************************************
#endcomment
func gettaskstring : string
intparm i, j
string Pending, Perm, TaskType, TaskString, KeyString, BBSNamen
string char, BBS_X, Item_X, BBSi, Itemi
strfmt BBS_X "BBS_%d" i
profilerd MailRun "MailRun" BBS_X BBSi
if j == 0
;if this is for a BBS name
profilerd MailRun BBSi "BBSName" BBSNamen
strfmt TaskString "%s`t`t`t%d`t%d" BBSNamen i j
else
;if this is for an item
strfmt Item_X "Item_%d" j
profilerd MailRun BBSi Item_X Itemi
strextract Pending Itemi "," 0
strextract Perm Itemi "," 1
strextract TaskType Itemi "," 2
if strcmpi Pending "1"
If strcmpi Perm "1"
char = "#"
else
char = "ñ"
endif
elseif strcmpi Pending "0"
char = "@"
else
char = " !"
endif
switch TaskType
case "SendMail"
TaskString = "Send REP Packet"
endcase
case "GetMail"
TaskString = "Get QWK Packet"
endcase
case "SendFile"
strextract KeyString Itemi "," 3
strextract Conf Itemi "," 4
strfmt TaskString "Upload %s to Conference %s" KeyString Conf
endcase
case "GetFile"
strextract keystring Itemi "," 3
strextract Conf Itemi "," 4
strfmt TaskString "Download %s from Conference %s" KeyString Conf
endcase
case "SendCommand"
strextract KeyString Itemi "," 3
strfmt TaskString "Send Command: %s" KeyString
endcase
case "SendScript"
strextract KeyString Itemi "," 3
strfmt TaskString "Execute Script: %s" KeyString
endcase
endswitch
strfmt TaskString "`t%s`t%s`t%d`t%d" char TaskString i j
endif
return TaskString
endfunc
#comment
*********************************************************************
*
* LOADSETTINGS()
*
* Called by:
* MRUN210H: makemrn(), changemailrun()
* MRUN210B: main()
*
* Initializes MailRun settings.
*
*********************************************************************
#endcomment
#ifdef MRUN210AB
proc loadsettings
string _MailRun
if FLAGS & DEFAULTS
_MailRun = MailRunIni
else
_MailRun = MailRun
endif
profilerd _MailRun "MailRun" "MailDir" MailDir
profilerd _MailRun "MailRun" "ReplyDir" ReplyDir
profilerd _MailRun "MailRun" "DownloadDir" DownloadDir
profilerd _MailRun "MailRun" "UploadDir" UploadDir
profilerd _MailRun "MailRun" "SavePackets" SavePackets
profilerd _MailRun "MailRun" "DialAttempts" DialAttempts
profilerd _MailRun "MailRun" "DialTimeout" DialTimeout
profilerd _MailRun "MailRun" "DialPause" DialPause
profilerd _MailRun "MailRun" "IdleTimeout" IdleTimeout
profilerd _MailRun "MailRun" "LogRun" LogRun
profilerd _MailRun "MailRun" "AppendLog" AppendLog
profilerd _MailRun "MailRun" "AnsiInLog" AnsiInLog
profilerd _MailRun "MailRun" "NewfileFilter" NewfileFilter
profilerd _MailRun "MailRun" "Archiver" Archiver
profilerd _MailRun "MailRun" "QWKReader" QWKReader
profilerd _MailRun "MailRun" "LogViewer" LogViewer
itoa IdleTimeout IdleTime
endproc
#endif
#comment
*********************************************************************
*
* WRITESETTINGS()
*
* Called by:
* MRUN210H: makemrn()
* MRUN210B: main()
*
* Writes MailRun settings to the *.MRN file.
*
*********************************************************************
#endcomment
#ifdef MRUN210AB
proc writesettings
string _MailRun
if FLAGS & DEFAULTS
_MailRun = MailRunIni
else
_MailRun = MailRun
endif
atoi IdleTime IdleTimeout
profilewr _MailRun "MailRun" "MailDir" MailDir
profilewr _MailRun "MailRun" "ReplyDir" ReplyDir
profilewr _MailRun "MailRun" "DownloadDir" DownloadDir
profilewr _MailRun "MailRun" "UploadDir" UploadDir
profilewr _MailRun "MailRun" "DialAttempts" DialAttempts
profilewr _MailRun "MailRun" "DialTimeout" DialTimeout
profilewr _MailRun "MailRun" "DialPause" DialPause
profilewr _MailRun "MailRun" "IdleTimeout" IdleTimeout
profilewr _MailRun "MailRun" "SavePackets" SavePackets
profilewr _MailRun "MailRun" "LogRun" LogRun
profilewr _MailRun "MailRun" "AppendLog" AppendLog
profilewr _MailRun "MailRun" "AnsiInLog" AnsiInLog
profilewr _MailRun "MailRun" "NewfileFilter" NewfileFilter
profilewr _MailRun "MailRun" "Archiver" Archiver
profilewr _MailRun "MailRun" "QWKReader" QWKReader
profilewr _MailRun "MailRun" "LogViewer" LogViewer
endproc
#endif
#comment
*********************************************************************
*
* LOADBBSINFO()
*
* Called by:
* MRUN210H: makemrn(), editcopy(), editpaste()
* MRUN210C: changeuserinfo(), addbbs()
*
* Initializes BBS information.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc loadbbsinfo
string _BBS
if FLAGS & DEFAULTS
_BBS = "DEFAULT"
else
_BBS = BBS
endif
profilerd MailRun _BBS "BBSName" BBSName
profilerd MailRun _BBS "UserName" UserName
profilerd MailRun _BBS "PWord" Pword
profilerd MailRun _BBS "XferProt" XferProt
profilerd MailRun _BBS "MailXferProt" MailXferProt
profilerd MailRun _BBS "QWKArchiver" QWKArchiver
profilerd MailRun _BBS "Number_1" Number_1
profilerd MailRun _BBS "Number_2" Number_2
profilerd MailRun _BBS "Number_3" Number_3
profilerd MailRun _BBS "BBSType" BBSType
profilerd MailRun _BBS "MailDoorType" MailDoorType
endproc
#endif
#endif
#endif
#comment
*********************************************************************
*
* WRITEBBSINFO()
*
* Called by:
* MRUN210H: makemrn(), editcopy(), editpaste()
* MRUN210C: changeuserinfo()
*
* Writes information for current BBS to the *.MRN file.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc writebbsinfo
string _BBS
if FLAGS & DEFAULTS
_BBS = "DEFAULT"
else
_BBS = BBS
endif
profilewr MailRun _BBS "BBSName" BBSName
profilewr MailRun _BBS "UserName" UserName
profilewr MailRun _BBS "PWord" PWord
profilewr MailRun _BBS "XferProt" XferProt
profilewr MailRun _BBS "MailXferProt" MailXferProt
profilewr MailRun _BBS "QWKArchiver" QWKArchiver
profilewr MailRun _BBS "Number_1" Number_1
profilewr MailRun _BBS "Number_2" Number_2
profilewr MailRun _BBS "Number_3" Number_3
profilewr MailRun _BBS "BBSType" BBSType
profilewr MailRun _BBS "MailDoorType" MailDoorType
endproc
#endif
#endif
#endif
#comment
*********************************************************************
*
* LOADPROMPTS()
*
* Called by:
* MRUN210H: makemrn(), editcopy(), editpaste()
* MRUN210C: changeuserinfo(), changeprompts(), addbbs()
*
* Initializes BBS prompts.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc loadprompts
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = BBSType
else
_MailRun = MailRun
_BBS = BBS
endif
profilerd _MailRun _BBS "CallingFrom" CallingFrom
profilerd _MailRun _BBS "UserResp1" UserResp1
profilerd _MailRun _BBS "UserResp2" UserResp2
profilerd _MailRun _BBS "LangNumber" LangNumber
profilerd _MailRun _BBS "GraphicsOn" GraphicsOn
profilerd _MailRun _BBS "LangPrompt" LangPrompt
profilerd _MailRun _BBS "GraphicsPrompt" GraphicsPrompt
profilerd _MailRun _BBS "NamePrompt" NamePrompt
profilerd _MailRun _BBS "PWordPrompt" PWordPrompt
profilerd _MailRun _BBS "UserPrompt1" UserPrompt1
profilerd _MailRun _BBS "UserPrompt2" UserPrompt2
profilerd _MailRun _BBS "ViewPrompt" ViewPrompt
profilerd _MailRun _BBS "ScanPrompt" ScanPrompt
profilerd _MailRun _BBS "FilePrompt" FilePrompt
profilerd _MailRun _BBS "MorePrompt" MorePrompt
profilerd _MailRun _BBS "ContinuePrompt" ContinuePrompt
profilerd _MailRun _BBS "CommandPrompt" CommandPrompt
profilerd _MailRun _BBS "DLPrompt" DLPrompt
profilerd _MailRun _BBS "DLUnavPrompt" DLUnavPrompt
profilerd _MailRun _BBS "ULPrompt" ULPrompt
profilerd _MailRun _BBS "ULDescPrompt" ULDescPrompt
endproc
#endif
#endif
#endif
#comment
*********************************************************************
*
* WRITEPROMPTS()
*
* Called by:
* MRUN210H: makemrn(), editcopy(), editpaste()
* MRUN210C: changeuserinfo(), changeprompts(), exportprompts()
*
* Writes prompts for current BBS to the *.MRN file.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc writeprompts
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = BBSType
else
_MailRun = MailRun
_BBS = BBS
endif
profilewr _MailRun _BBS "CallingFrom" CallingFrom
profilewr _MailRun _BBS "UserResp1" UserResp1
profilewr _MailRun _BBS "UserResp2" UserResp2
profilewr _MailRun _BBS "LangNumber" LangNumber
profilewr _MailRun _BBS "GraphicsOn" GraphicsOn
profilewr _MailRun _BBS "LangPrompt" LangPrompt
profilewr _MailRun _BBS "GraphicsPrompt" GraphicsPrompt
profilewr _MailRun _BBS "NamePrompt" NamePrompt
profilewr _MailRun _BBS "PWordPrompt" PWordPrompt
profilewr _MailRun _BBS "UserPrompt1" UserPrompt1
profilewr _MailRun _BBS "UserPrompt2" UserPrompt2
profilewr _MailRun _BBS "ViewPrompt" ViewPrompt
profilewr _MailRun _BBS "ScanPrompt" ScanPrompt
profilewr _MailRun _BBS "FilePrompt" FilePrompt
profilewr _MailRun _BBS "MorePrompt" MorePrompt
profilewr _MailRun _BBS "ContinuePrompt" ContinuePrompt
profilewr _MailRun _BBS "CommandPrompt" CommandPrompt
profilewr _MailRun _BBS "DLPrompt" DLPrompt
profilewr _MailRun _BBS "DLUnavPrompt" DLUnavPrompt
profilewr _MailRun _BBS "ULPrompt" ULPrompt
profilewr _MailRun _BBS "ULDescPrompt" ULDescPrompt
endproc
#endif
#endif
#endif
#comment
*********************************************************************
*
* LOADMAILDOOR()
*
* Called by:
* MRUN210H: makemrn(), editcopy(), editpaste()
* MRUN210C: changeuserinfo(), changemaildoor(), addbbs()
*
* Initializes mail door prompts.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc loadmaildoor
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = MailDoorType
else
_MailRun = MailRun
_BBS = BBS
endif
profilerd _MailRun _BBS "MailDoor" MailDoor
profilerd _MailRun _BBS "MailPrompt" MailPrompt
profilerd _MailRun _BBS "ReceiveQWKPrompt" ReceiveQWKPrompt
profilerd _MailRun _BBS "MailDLPrompt" MailDLPrompt
profilerd _MailRun _BBS "MailULPrompt" MailULPrompt
profilerd _MailRun _BBS "MsgMenuPrompt" MsgMenuPrompt
endproc
#endif
#endif
#endif
#comment
*********************************************************************
*
* WRITEMAILDOOR()
*
* Called by:
* MRUN210H: makemrn(), editcopy(), editpaste()
* MRUN210C: changeuserinfo(), changemaildoor(),
* exportmaildoor()
*
* Writes mail door prompts for the current BBS to the .MRN
* file.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc writemaildoor
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = MailDoorType
else
_MailRun = MailRun
_BBS = BBS
endif
profilewr _MailRun _BBS "MailDoor" MailDoor
profilewr _MailRun _BBS "MailPrompt" MailPrompt
profilewr _MailRun _BBS "ReceiveQWKPrompt" ReceiveQWKPrompt
profilewr _MailRun _BBS "MailDLPrompt" MailDLPrompt
profilewr _MailRun _BBS "MailULPrompt" MailULPrompt
profilewr _MailRun _BBS "MsgMenuPrompt" MsgMenuPrompt
endproc
#endif
#endif
#endif
#comment
*********************************************************************
*
* OPENFILE()
*
* Calls fileexit()
*
* Called by:
* MRUN210H: maketasklist(), makedesc(), clearfiledesc(),
* sortidx(), taskfilefwd()
* MRUN210D: main(), purgeoldfiles(), getnewfiles(),
* import(), deldlfile()
* MRUN210E: insertulfile(), killfile(), getulfiles(),
* updateudx()
* MRUN210F: makescriptlist()
* MRUN210G: makequeue(), getdialstring(), senddesc(), putdesc()
*
* Opens a file in the manner specified. If the file could
* not be opened successfully, displays an error message and
* terminates the script.
*
*********************************************************************
#endcomment
proc openfile
intparm FileIndex
strparm FileNamen
intparm OpenMethod, OpenType
switch OpenMethod
case _CREATE
switch OpenType
case _TEXT
fopen FileIndex FileNamen CREATE TEXT
endcase
case _NORMAL
fopen FileIndex FileNamen CREATE
endcase
endswitch
endcase
case _READWRITE
switch OpenType
case _TEXT
fopen FileIndex FileNamen READWRITE TEXT
endcase
case _NORMAL
fopen FileIndex FileNamen READWRITE
endcase
endswitch
endcase
endswitch
if FAILURE
errormsg "Unable to open file %s;`r`nscript aborted...." FileNamen
fileexit()
endif
endproc
#comment
*********************************************************************
*
* READBBS()
*
* Called by:
* MRUN210H: makebbslist(), maketasklist(), getbbscoord(),
* getbbsi(), insertbbs(), editdelete(),
* filereset()
* MRUN210A: swapbbs()
* MRUN210G: main(), makequeue()
*
* Reads the BBS associated with a BBS coordinate in the
* current mailrun.
*
*********************************************************************
#endcomment
func readbbs : string
intparm i
string BBS_X, BBSi
strfmt BBS_X "BBS_%d" i
profilerd MailRun "MailRun" BBS_X BBSi
return BBSi
endfunc
#comment
*********************************************************************
*
* READITEM()
*
* Called by:
* MRUN210H: maketasklist(), getitemcoord(), getitemi(),
* insertitem(), editdelete(), filereset(),
* changestatus(), checkpending(), editcopy()
* MRUN210A: swapitem()
* MRUN210G: dobbs()
*
* Reads the Item associated with a BBS coordinate in the
* current mailrun.
*
*********************************************************************
#endcomment
func readitem : string
intparm i
string Item_X, Itemi
strfmt Item_X "Item_%d" i
profilerd MailRun BBS Item_X Itemi
return Itemi
endfunc
#comment
*********************************************************************
*
* WRITEBBS()
*
* Called by:
* MRUN210H: insertbbs(), editdelete()
* MRUN210A: swapbbs()
* MRUN210C: writenewbbs()
*
* Writes a BBS ID to the given coordinate in the current
* mailrun.
*
*********************************************************************
#endcomment
proc writebbs
intparm i
strparm BBSi
string BBS_X
strfmt BBS_X "BBS_%d" i
profilewr MailRun "MailRun" BBS_X BBSi
endproc
#comment
*********************************************************************
*
* WRITEITEM()
*
* Called by:
* MRUN210H: insertitem(), editdelete(), filereset(),
* changestatus()
* MRUN210A: swapitem()
* MRUN210G: dobbs()
*
* Writes an Item to the given Item coordinate for the
* current BBS and MailRun.
*
*********************************************************************
#endcomment
proc writeitem
intparm i
strparm Itemi
string Item_X
strfmt Item_X "Item_%d" i
profilewr MailRun BBS Item_X Itemi
endproc
#comment
*********************************************************************
*
* GETBBSCOORD()
*
* Calls readbbs()
*
* Called by:
* MRUN210C: changeuserinfo(), changeprompts(), changemaildoor()
* MRUN210D: main()
* MRUN210E: main()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Gets the BBS coordinate for a given BBS ID.
*
*********************************************************************
#endcomment
func getbbscoord : integer
integer i
string BBSi
i = 1
BBSi = readbbs(i)
while not strcmpi BBS BBSi
i++
BBSi = readbbs(i)
endwhile
return i
endfunc
#comment
*********************************************************************
*
* GETITEMCOORD()
*
* Calls readitem()
*
* Called by:
* MRUN210D: main()
* MRUN210E: main()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Gets the Item coordinate for a given Item in the current
* BBS.
*
*********************************************************************
#endcomment
func getitemcoord : integer
integer i
i = 1
Item = readitem(i)
while not NULLSTR Item
i++
Item = readitem(i)
endwhile
i--
Item = readitem(i)
return i
endfunc
#comment
*********************************************************************
*
* GETBBSI()
*
* Calls readbbs()
*
* Called by:
* MRUN210H: editdelete(), changestatus(), editcopy(),
* editpaste()
* MRUN210A: parsekeystate()
* MRUN210C: changeuserinfo(), changeprompts(), changemaildoor()
* MRUN210D: main()
* MRUN210E: main()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Gets the BBS ID associated with the currently selected
* item in the task list. Returns the integer value of the
* BBS coordinate.
*
*********************************************************************
#endcomment
func getbbsi : integer
string char
integer i
strextract char TaskItem "`t" 3
atoi char i
BBS = readbbs(i)
return i
endfunc
#comment
*********************************************************************
*
* GETITEMI()
*
* Calls readitem()
*
* Called by:
* MRUN210H: editdelete(), changestatus(), editcopy(),
* editpaste()
* MRUN210A: parsekeystate()
* MRUN210D: main()
* MRUN210E: main()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Gets the Item associated with the currently selected item
* in the task list. Returns the integer value of the Item
* coordinate.
*
*********************************************************************
#endcomment
func getitemi : integer
string char
integer i
strextract char TaskItem "`t" 4
atoi char i
Item = readitem(i)
return i
endfunc
#comment
*********************************************************************
*
* GETFIRSTITEM()
*
* Called by:
* MRUN210H: filereset(), filedelmrun(), callscript()
* MRUN210A: main(), parsedialog()
*
* Highlights the first item in the task list.
*
*********************************************************************
#endcomment
proc getfirstitem
string BBSNamen
profilerd MailRun "MailRun" "BBS_1" BBS
if not NULLSTR BBS
profilerd MailRun BBS "BBSName" BBSNamen
strfmt TaskItem "%s`t`t`t%d`t%d" BBSNamen 1 0
else
TaskItem = ""
endif
endproc
#comment
*********************************************************************
*
* COPYMRN()
*
* Calls makefullname()
*
* Called by:
* MRUN210H: changemailrun(), filesaveas(), filedelmrun()
*
* Copies a mailrun from MailRunDir to TempDir.
*
*********************************************************************
#endcomment
#ifdef MRUN210AB
proc copymrn
string LastRun
delfile MailRun
LastRun = makefullname(MailRunDir, MailRunTrunc)
MailRun = makefullname(TempDir, MailRunTrunc)
copyfile LastRun MailRun
endproc
#endif
#comment
*********************************************************************
*
* FVERIFY()
*
* Called by:
* MRUN210H: filesaveas()
* MRUN210B: newmailrun()
* MRUN210C: addbbs()
*
* Checks for a valid DOS filename (sans extension).
* Returns 1 if valid, 0 if invalid.
*
*********************************************************************
#endcomment
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
func fverify : integer
strparm LookString
string DOSChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&()-_{}"
string char
integer i, j
strlen LookString i
if (i > 8) || (i == 0)
return 0
else
i = 0
strpeek LookString i j
while j != 0
strfmt char "%c" j
if not strfind DOSChars char
return 0
endif
i++
strpeek LookString i j
endwhile
return 1
endif
endfunc
#endif
#endif
#endif
#comment
*********************************************************************
*
* CLEARDIR()
*
* Calls makefullname()
*
* Called by:
* MRUN210H: fileexit()
* MRUN210A: initialize()
* MRUN210G: getmail()
*
* Deletes the contents of a directory.
*
*********************************************************************
#endcomment
proc cleardir
strparm DirName
string DeadFile, DirFiles
DirFiles = makefullname(DirName, "*.*")
findfirst DirFiles
while FOUND
DeadFile = makefullname(DirName, $FILENAME)
delfile DeadFile
findnext
endwhile
endproc
#comment
*********************************************************************
*
* CLEARFILEDESC()
*
* Calls openfile()
*
* Called by:
* MRUN210D: main(), deldlfile()
* MRUN210E: main(), insertulfile(), killfile()
*
* Clears the current file description box by creating a
* new file.
*
*********************************************************************
#endcomment
#ifdef MRUN210DE
proc clearfiledesc
openfile(FileDescFile, FileDesc, _CREATE, _NORMAL)
fclose FileDescFile
endproc
#endif
#comment
*********************************************************************
*
* INSERTITEM()
*
* Calls readitem(), writeitem()
*
* Called by:
* MRUN210H: editpaste()
* MRUN210D: main()
* MRUN210E: insertulfile()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Inserts a new item into the *.MRN file.
*
*********************************************************************
#endcomment
proc insertitem
intparm i
strparm NovumItem
integer j, k
j = i - 1
Item = readitem(i)
while not NULLSTR Item
i++
Item = readitem(i)
endwhile
k = i - 1
while k > j
Item = readitem(k)
writeitem(i, Item)
i--
k--
endwhile
writeitem(i, NovumItem)
Item = NovumItem
endproc
#comment
*********************************************************************
*
* INSERTBBS()
*
* Calls readbbs(), writebbs()
*
* Called by:
* MRUN210H: editpaste()
* MRUN210C: writenewbbs()
*
* Inserts a new BBS into the *.MRN file.
*
*********************************************************************
#endcomment
#ifndef MRUN210B
#ifndef MRUN210DE
#ifndef MRUN210F
#ifndef MRUN210G
proc insertbbs
intparm i
strparm NewBBS
string BBSi
integer j, k
j = i + 1
BBSi = readbbs(j)
;Go to the last BBS
while not NULLSTR BBSi
j++
BBSi = readbbs(j)
endwhile
k = j - 1
;Count back down, renumbering on the way
while k > i
BBSi = readbbs(k)
writebbs(j, BBSi)
j--
k--
endwhile
writebbs(j, NewBBS)
endproc
#endif
#endif
#endif
#endif
#comment
*********************************************************************
*
* CHANGEMAILRUN()
*
* Calls filesave(), copymrn(), loadsettings()
*
* Called by:
* MRUN210A: parsedialog()
* MRUN210B: main()
*
* Saves the last mailrun and loads a new one.
*
*********************************************************************
#endcomment
#ifdef MRUN210AB
proc changemailrun
;Update the last mailrun
filesave()
;Get the next mailrun and copy it to the temp directory
copymrn()
loadsettings()
endproc
#endif
#comment
*********************************************************************
*
* CHECKPENDING()
*
* Calls readitem()
*
* Called by:
* MRUN210H: changestatus()
* MRUN210G: makequeue()
*
* Checks a BBS for currently pending items. Returns "1" if
* items are pending, "0" if none are pending.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
func checkpending : string
string Pending = "0"
integer i
i = 1
Item = readitem(i)
while not NULLSTR Item
strextract pending Item "," 0
if strcmpi Pending "1"
exitwhile
endif
i++
Item = readitem(i)
endwhile
return Pending
endfunc
#endif
#comment
*********************************************************************
*
* CHECKPERM()
*
* Called by:
* MRUN210D: main()
* MRUN210E: insertulfile()
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
*
* Checks the Temporary/Permanent radiobutton set; returns
* 1 if Permanent (button 1) is selected, 0 if Temporary
* (button 2).
*
*********************************************************************
#endcomment
#ifndef MRUN210AG
#ifndef MRUN210C
#ifndef MRUN210B
func checkperm : string
string Perm
if PermRadio == 1
Perm = "1"
else
Perm = "0"
endif
return Perm
endfunc
#endif
#endif
#endif
#comment
*********************************************************************
*
* CHECKCHILD()
*
* Called by:
* MRUN210A-G: main()
*
* Halts the script if the current script has not been
* called by another script.
*
*********************************************************************
#endcomment
proc checkchild
if not ($CHILD || $CHAINED)
errormsg "This script can only be run from MRUN210.WAX."
halt
endif
endproc
#comment
*********************************************************************
*
* CHECKRUNNING()
*
* Called by:
* MRUN210H: filenewmrun()
*
* Checks whether a mailrun is executing. Returns 0 and
* generates a message if running, returns 1 if not.
*
*********************************************************************
#endcomment
#ifndef MRUN210G
func checkrunning : integer
if FLAGS & RUNNING
usermsg "You cannot create a new mailrun while a mailrun is executing."
return 0
else
return 1
endif
endfunc
#endif
#comment
*********************************************************************
*
* CHECKCHANGED()
*
* Called by:
* MRUN210H: filenewmrun(), cfgmrun(), cfgbbs(), cfgprompts(),
* cfgmaildoor(), defaultsmailrun(), defaultsbbs(),
* defaultsprompts(), defaultsdoor(), addnewbbs(),
* addgetsend(), adddownload(), addupload(),
* addsendcmd(), addscript(), helpabout()
* MRUN210B: main()
* MRUN210C: changebbsinfo(), changeprompts(), changemaildoor()
* MRUN210E: main()
*
* Checks whether the contents of the current dialog box
* have changed and generates a warning. Returns 1 if
* user elects to proceed or if there has been no change,
* 0 if user cancels.
*
*********************************************************************
#endcomment
func checkchanged : integer
integer Response
if FLAGS & CHANGED
sdlgmsgbox "MailRun Message" "Discard Changes?" QUESTION YESNO \
Response 2
switch Response
case 6
FLAGS &= UNCHANGED
return 1
endcase
case 7
return 0
endcase
endswitch
else
return 1
endif
endfunc
#comment
*********************************************************************
*
* CHECKFILE()
*
* Called by:
* MRUN210A: initialize()
* MRUN210D: purgeoldfiles(), getnewfiles(), import()
* MRUN210E: main(), getulfiles()
* MRUN210G: senddesc(), putdesc()
*
* Checks for a file's existence. Returns 1 if the file is
* found, 0 if not found.
*
*********************************************************************
#endcomment
#ifndef MRUN210BC
#ifndef MRUN210F
func checkfile : integer
strparm FileNom
if isfile FileNom
return 1
else
return 0
endif
endfunc
#endif
#endif
#comment
*********************************************************************
*
* CHECKTASK()
*
* Called by:
* MRUN210H: executearchiver(), executeqwkreader(),
* executelogviewer()
*
* Returns 1 if the specified application is already running;
* otherwise returns 0.
*
*********************************************************************
#endcomment
func checktask : integer
strparm Called
string AppName
integer i
firsttask i
while i
taskname i AppName
if strfind Called AppName
return i
endif
nexttask i
endwhile
return 0
endfunc
#comment
*********************************************************************
*
* CHECKNEW()
*
* Called by:
* MRUN210H: cfgbbs(), cfgprompts(), cfgmaildoor(),
* addgetsend(), adddlfile(), addulfile(),
* addsendcmd(), addscript()
*
* Returns 0 if the current mailrun is empty; else returns 1.
*
*********************************************************************
#endcomment
func checknew : integer
if NULLSTR TaskItem
usermsg "You must add a BBS before selecting this function!"
return 0
else
return 1
endif
endfunc
#comment
*********************************************************************
*
* MENUDIM()
*
* Called by:
* MRUN210H: callscript()
* MRUN210B-G: main()
*
* Enables all menu controls, then disables those which
* cannot be used in the current module.
*
*********************************************************************
#endcomment
proc menudim
enable MENU 1 32
#ifndef MRUN210AG
disable MENU 3 5
disable MENU 8 11
#endif
#ifdef MRUN210G
disable MENU 1
disable MENU 3
disable MENU 5 6
#endif
endproc
#comment
*********************************************************************
*
* SORTIDX()
*
* Calls fieldcompare(), makefullname(), openfile(),
* interfaceoff(), interfaceon()
*
* Called by:
* MRUN210D: main(), getnewfiles()
* MRUN210E: main(), getulfiles(), updateudx()
*
* Sorts an index file for display in the upload or download
* dialog box. This routine uses two temp files to sort the
* contents of the referenced file. It is used to sort an
* index file that has not been previously sorted. The
* method used is too slow when only a couple of new items
* need to be sorted in the file.
*
*********************************************************************
#endcomment
#ifdef MRUN210DE
proc sortidx
strparm idxName
intparm SortField
string temp1, temp2, Line1, Line2, LastLine
integer Unsorted, Readidx, Writeidx, i, counter
SortField -=2
if SortField < 0
return
endif
interfaceoff()
counter = 0
temp1 = makefullname(TempDir, "temp1.tmp")
temp2 = makefullname(TempDir, "temp2.tmp")
Unsorted = 0
Readidx = 1
Writeidx = 2
openfile(Unsorted, idxName, _READWRITE, _TEXT)
fgets Unsorted Line1
statmsg "Sorting... %d" counter
if feof Unsorted
;if the index is empty, return
fclose Unsorted
interfaceon()
return
else
;otherwise, open temp files and sort
openfile(Readidx, temp1, _CREATE, _TEXT)
openfile(Writeidx, temp2, _CREATE, _TEXT)
;put the first line into the read file
fputs Readidx Line1
rewind Readidx
;get the next line of the unsorted file
fgets Unsorted Line1
counter++
statmsg "Sorting... %d" counter
fgets Readidx Line2
if feof Unsorted
;prevents a single file from being deleted
fputs Writeidx Line2
endif
while not feof Unsorted
while not feof Readidx
if fieldcompare(Line1, Line2, SortField)
exitwhile
endif
fputs Writeidx Line2
fgets Readidx Line2
endwhile
fputs Writeidx Line1
LastLine = Line1
fgets Unsorted Line1
counter++
statmsg "Sorting... %d" counter
if feof Unsorted
while not feof Readidx
fputs Writeidx Line2
fgets Readidx Line2
endwhile
exitwhile
elseif !(fieldcompare(Line1, LastLine, SortField))
loopwhile
endif
while not feof Readidx
fputs Writeidx Line2
fgets Readidx Line2
endwhile
rewind Readidx
rewind Writeidx
i = Readidx
Readidx = Writeidx
Writeidx = i
fgets Readidx Line2
endwhile
fclose Unsorted
fclose Readidx
fclose Writeidx
delfile idxName
if Writeidx == 1
copyfile temp1 idxName
else
copyfile temp2 idxName
endif
delfile temp1
delfile temp2
endif
statmsg ""
interfaceon()
endproc
#endif
#comment
*********************************************************************
*
* FIELDCOMPARE()
*
* Called by:
* MRUN210H: sortidx()
*
* Compares two fields. Returns 0 if Field1 > Field2,
* 1 if Field1 <= Field2.
*
*********************************************************************
#endcomment
#ifdef MRUN210DE
func fieldcompare : integer
strparm Line1, Line2
intparm FieldType
string Field1, Field2
long number1, number2, Date1, Date2
strextract Field1 Line1 "`t" FieldType
strextract Field2 Line2 "`t" FieldType
switch FieldType
case ALPHA
strcmpi Field1 Field2
if $STRCMP >= 0
return 0
else
return 1
endif
endcase
case NUMERIC
atol Field1 number1
atol Field2 number2
if number1 >= number2
return 0
else
return 1
endif
endcase
case MMDDYY
strsltime Field1 "00:00:00" Date1
strsltime Field2 "00:00:00" Date2
if Date1 >= Date2
return 0
else
return 1
endif
endcase
endswitch
endfunc
#endif
#comment
*********************************************************************
*
* FINDSTRING()
*
* Called by:
* MRUN210B: main()
* MRUN210C: exportprompts()
* MRUN210D: getnewfiles(), import()
* MRUN210E: shortdesc()
* MRUN210G: main(), checkcommandprompt(), getconfprompt(),
* checkmailprompt(), checkdescprompt(),
* checkbaseset(), getotherprompt(), sendmail(),
* getmail(), checkmail(), ulfile(), checkverifyprompt(),
* senddesc(), dlfile(), sendcommand(), sendscript()
*
* Returns a value of 1 if the second string is contained
* in the first string; otherwise returns 0.
*
*********************************************************************
#endcomment
#ifndef MRUN210A
#ifndef MRUN210F
func findstring : integer
strparm String1, String2
integer i = 0
if not NULLSTR String2
if strfind String1 String2
i = 1
endif
endif
return i
endfunc
#endif
#endif
#comment
**************************************************************************
**************************************************************************
*
* The following routines comprise the user interface of MailRun.
* parsedialog controls the behavior of the main mailrun dialog box,
* parsemenu() controls the menu and parseobject() controls the
* toolbar. The menus and toolbar are defined in MRUN210A in the
* procedures mrunmenu(), which creates the main menu system,
* runmenu(), which creates the alternate menu used when a mailrun
* is executing, and mrunwin(), which creates the toolbar.
*
**************************************************************************
**************************************************************************
#comment
#comment
*********************************************************************
*
* INTERFACEON()
*
* Calls parsemenu(), parseobject()
*
* Called by:
* MRUN210H: sortidx(), taskfileend()
* MRUN210A: main()
* MRUN210B: main()
* MRUN210C: changeuserinfo(), changeprompts(), changemaildoor()
* MRUN210D: main(), purgeoldfiles(), getnewfiles(), deldlfile()
* MRUN210E: main(), insertulfile(), getulfiles(), updateudx(),
* MRUN210F: addgetmail(), addsendcommand(), adddoscript()
* MRUN210G: makequeue(), getdialstring(), senddesc(), putdesc()
*
* Activate and deactivate the menu and iconbar.
*
*********************************************************************
#endcomment
proc interfaceon
when menu call parsemenu
when object call parseobject
endproc
#comment
*********************************************************************
*
* INTERFACEOFF()
*
* Called by:
* MRUN210H: sortidx(), taskfilefwd()
* MRUN210D: main(), purgeoldfiles(), getnewfiles(), deldlfile()
* MRUN210E: insertulfile(), geulfiles(), updateudx()
* MRUN210G: makequeue(), getdialstring(), senddesc(), putdesc()
*
* Activate and deactivate the menu and iconbar.
*
*********************************************************************
#endcomment
#ifndef MRUN210BC
#ifndef MRUN210F
proc interfaceoff
clearwhen menu
clearwhen object
endproc
#endif
#endif
#comment
*********************************************************************
*
* PARSEDIALOG()
*
* Calls changestatus(), changemailrun(), maketasklist(),
* getfirstitem(), gettaskstring(), getbbsi(), getitemi(),
* swapbbs(), swapitem()
*
* Called by
* MRUN210A: main(), executor()
* MRUN210G: main()
*
* Checks for dialog box selection and dispatches the
* appropriate task.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc parsedialog
integer dialogstatus, i, j, k
#ifdef MRUN210G
string LastBBS, LastItem
LastBBS = BBS
LastItem = Item
#endif
dialogstatus = $DIALOG
switch dialogstatus
case 10
;User double clicked on an item
changestatus()
updatedlg 80
endcase
case 11
;User selected Alt-U to move an item up
i = getbbsi()
j = getitemi()
if j == 0
;if the selected TaskItem is a BBS
k = i - 1
swapbbs(i, k)
else
;if the selected TaskItem is an Item
j--
if swapitem(i, j)
TaskItem = gettaskstring(i, j)
endif
endif
updatedlg 80
endcase
case 12
;User selected Alt-I to move an item down
i = getbbsi()
j = getitemi()
if j == 0
;If the selected TaskItem is a BBS
k = i + 1
swapbbs(i, k)
else
;If the selected TaskItem is an Item
if swapitem(i, j)
j++
TaskItem = gettaskstring(i, j)
endif
endif
updatedlg 80
endcase
#ifdef MRUN210A
case 170
;User changed mailruns with combobox
changemailrun()
maketasklist()
getfirstitem()
updatedlg 80
endcase
#endif
endswitch
#ifdef MRUN210G
makequeue()
BBS = LastBBS
Item = LastItem
#endif
endproc
#endif
#comment
*********************************************************************
*
* SWAPBBS()
*
* Calls readbbs(), writebbs(), maketasklist()
*
* Called by:
* MRUN210H: parsedialog()
*
* Swaps two BBSs in the task list.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc swapbbs
intparm i, k
string OldBBS, BBSNamen
OldBBS = readbbs(k)
if not NULLSTR OldBBS
;Unless this is the last (or first) BBS, swap with the next BBS
writebbs(i, OldBBS)
writebbs(k, BBS)
maketasklist()
profilerd MailRun BBS "BBSName" BBSNamen
strfmt TaskItem "%s`t`t`t%d`t%d" BBSNamen k 0
endif
endproc
#endif
#comment
*********************************************************************
*
* SWAPITEM()
*
* Calls readitem(), writeitem(), gettaskstring(), taskfilefwd(),
* taskfileend()
*
* Called by:
* MRUN210H: parsedialog()
*
* Swaps two Items in the task list.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
func swapitem : integer
intparm i, j
string Itemj, Iteml, TaskString
integer l
l = j + 1
Itemj = readitem(j)
Iteml = readitem(l)
if j == 0
return 0
endif
if not NULLSTR Iteml
;Unless this is the last Item, swap with the next Item
taskfilefwd(i, j)
writeitem(j, Iteml)
writeitem(l, Itemj)
TaskString = gettaskstring(i, j)
fputs TaskFile TaskString
TaskString = gettaskstring(i, l)
fputs TaskFile TaskString
fgets OldTaskFile TaskString
taskfileend()
return 1
else
return 0
endif
endfunc
#endif
#comment
*********************************************************************
*
* CHANGESTATUS()
*
* Calls getbbsi(), getitemi(), readitem(), writeitem(),
* maketasklist(), gettaskstring(), checkpending(), taskfilefwd()
* taskfileend()
*
* Called by:
* MRUN210H: parsedialog()
*
* Changes the pending/complete permanent/temporary status
* of the selected item on the task list. Responds to user
* double-clicking on the item.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc changestatus
string Pending, Perm, BBSNamen
integer i, j, ItemC, ItemE, ItemR
i = getbbsi()
j = getitemi()
if j == 0
;If the item is a BBS
;Check for pending items
Pending = checkpending()
if strcmpi Pending "0"
;If no items are pending, set all to pending status
Pending = "1"
else
;If at least one item is pending, set all to completed status
Pending = "0"
endif
j = 1
Item = readitem(j)
;Update all items
while not NULLSTR Item
strupdt Item Pending 0 1
writeitem(j, Item)
j++
Item = readitem(j)
endwhile
maketasklist()
profilerd MailRun BBS "BBSName" BBSNamen
strfmt TaskItem "%s`t`t`t%d`t%d" BBSNamen i 0
else
;If it is not a BBS
Item = readitem(j)
atoi ItemComplete ItemC
atoi ItemRemaining ItemR
atoi ItemError ItemE
strextract Pending Item "," 0
strextract Perm Item "," 1
if not strcmpi Pending "1"
if strcmpi Pending "0"
ItemC--
else
ItemE--
endif
ItemR++
Pending = "1"
Perm = "0"
else
if strcmpi Perm "0"
Perm = "1"
else
Pending = "0"
ItemC++
ItemR--
endif
endif
itoa ItemC ItemComplete
itoa ItemR ItemRemaining
itoa ItemE ItemError
strupdt Item Pending 0 1
strupdt Item Perm 2 1
taskfilefwd(i, j)
writeitem(j, Item)
TaskItem = gettaskstring(i, j)
fputs TaskFile TaskItem
taskfileend()
endif
endproc
#endif
#comment
*********************************************************************
*
* TASKFILEFWD()
*
* Calls makefullname(), openfile(), interfaceoff()
*
* Called by:
* MRUN210H: swapitem(), changestatus()
*
* Opens the Task List file and moves forward to the designated
* coordinates.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc taskfilefwd
intparm i, j
string OldTasks, OldTaskString, TaskString
interfaceoff()
OldTasks = makefullname(TempDir, "oldtasks.tmp")
copyfile TaskList OldTasks
openfile(OldTaskFile, OldTasks, _READWRITE, _TEXT)
openfile(TaskFile, TaskList, _CREATE, _TEXT)
OldTaskString = gettaskstring(i, j)
fgets OldTaskFile TaskString
while not strcmpi OldTaskString TaskString
fputs TaskFile TaskString
fgets OldTaskFile TaskString
endwhile
endproc
#endif
#comment
*********************************************************************
*
* TASKFILEEND()
*
* Calls makefullname(), interfaceon()
*
* Called by:
* MRUN210H: swapitem(), changestatus()
*
* Reads to the end of the Task List file and closes it.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc taskfileend
string TaskString, OldTasks
fgets OldTaskFile TaskString
while not feof OldTaskFile
fputs TaskFile TaskString
fgets OldTaskFile TaskString
endwhile
fclose OldTaskFile
fclose TaskFile
OldTasks = makefullname(TempDir, "oldtasks.tmp")
delfile OldTasks
interfaceon()
endproc
#endif
#comment
*********************************************************************
*
* PARSEMENU()
*
* Calls filenewmrun(), filesave(), filesaveas(), filereset(),
* filedelmrun(), fileautorun(), fileexit(), editcut(), editcopy(),
* editpaste(), editdelete(), cfgmrun(), cfgbbs(), cfgprompts(),
* cfgmaildoor(), defaultsmailrun(), defaultsbbs(), defaultsprompts(),
* defaultsdoor(), addnewbbs(), addgetsend(), addupload(),
* adddownload(), addsendcmd(), addscript(), executemailrun(),
* executeqwkreader(), executearchiver(), executelogviewer(),
* helpcontents(), helpcontext(), helpabout()
*
* Called by:
* MRUN210H: interfaceon()
*
* Parses a selection from the MailRun menu.
*
*********************************************************************
#endcomment
proc parsemenu
integer menustatus
menustatus = $MENU
switch menustatus
#ifndef MRUN210G
case 1
;User selected file.new
filenewmrun()
endcase
#endif
case 2
;User selected file.save
filesave()
endcase
#ifdef MRUN210A
case 3
;User selected file.save_as
filesaveas()
endcase
#endif
#ifdef MRUN210AG
case 4
;User selected file.reset
filereset()
endcase
#endif
#ifdef MRUN210A
case 5
;User selected file.delete_mailrun
filedelmrun()
endcase
#endif
#ifndef MRUN210G
case 6
;User selected file.create_autorun
fileautorun()
endcase
#endif
case 7
;User selected file.exit
fileexit()
endcase
#ifdef MRUN210AG
case 8
;User selected edit.cut
editcut()
endcase
case 9
;User selected edit.copy
editcopy()
endcase
case 10
;User selected edit.paste
editpaste()
endcase
case 11
;User selected delete_item
editdelete()
endcase
#endif
case 12
;User selected configure.mailrun_settings
cfgmrun()
endcase
case 13
;User selected configure.bbs_settings
cfgbbs()
endcase
case 14
;User selected configure.bbs_prompts
cfgprompts()
endcase
case 15
;User selected configure.bbs_mail_door
cfgmaildoor()
endcase
case 16
;User selected configure.defaults.mailrun
defaultsmailrun()
endcase
case 17
;User selected configure.defaults.bbs
defaultsbbs()
endcase
case 18
;User selected configure.defaults.prompts
defaultsprompts()
endcase
case 19
;User selected configure.defaults.maildoor
defaultsdoor()
endcase
case 20
;User selected add.new_bbs
addnewbbs()
endcase
case 21
;User selected add.get/send_mail
addgetsend()
endcase
case 22
;User selected add.upload_file
addupload()
endcase
case 23
;User selected add.download_file
adddownload()
endcase
case 24
;User selected add.send_command
addsendcmd()
endcase
case 25
;User selected add.execute_script
addscript()
endcase
case 26
;User selected execute.mailrun
executemailrun()
endcase
case 27
;User selected execute.qwk_reader
executeqwkreader()
endcase
case 28
;User selected execute.archiver
executearchiver()
endcase
case 29
;User selected execute.view_log_file
executelogviewer()
endcase
case 30
;User selected help.contents
helpcontents()
endcase
case 31
;User selected help.current_window
helpcontext()
endcase
case 32
;User selected help.about
helpabout()
endcase
endswitch
endproc
#comment
*********************************************************************
*
* PARSEOBJECT()
*
* Calls executemailrun(), filereset(), filenewmrun(),
* cfgbbs(), addnewbbs(), addgetsend(), addupload(),
* adddownload(), addsendcmd(), addscript(), editdelete(),
* executelogviewer(), executeqwkreader(), executearchiver(),
* fileexit(), helpabout()
*
* Called by:
* MRUN210H: interfaceon()
*
* Parses a selection from the MailRun icon bar.
*
*********************************************************************
#endcomment
proc parseobject
integer objectstatus
objectstatus = $OBJECT
switch objectstatus
case 1
;User selected icon for execute.mailrun
executemailrun()
endcase
#ifdef MRUN210AG
case 2
;User selected icon for file.reset
filereset()
endcase
#endif
#ifndef MRUN210G
case 3
;User selected icon for file.new
filenewmrun()
endcase
#endif
case 4
;User selected icon for configure.bbs
cfgbbs()
endcase
case 5
;User selected icon for add.new_bbs
addnewbbs()
endcase
case 6
;User selected icon for add.get/send_mail
addgetsend()
endcase
case 7
;User selected icon for add.upload_file
addupload()
endcase
case 8
;User selected icon for add.download_file
adddownload()
endcase
case 9
;User selected icon for add.send_command
addsendcmd()
endcase
case 10
;User selected icon for add.execute_script
addscript()
endcase
#ifdef MRUN210AG
case 11
;User selected icon for file.delete_item
editdelete()
endcase
#endif
case 12
;User selected icon for execute.view_log_file
executelogviewer()
endcase
case 13
;User selected icon for execute.qwk_reader
executeqwkreader()
endcase
case 14
;User selected icon for execute.archiver
executearchiver()
endcase
case 15
;User selected icon for file.exit
fileexit()
endcase
case 16
;User selected icon for context sensitive help
helpcontext()
endcase
endswitch
endproc
#comment
**************************************************************************
**************************************************************************
*
* The following procedures correspond to menu selections
* and are called from parsemenu() and parseobject().
*
**************************************************************************
**************************************************************************
#endcomment
#comment
*********************************************************************
*
* FILENEWMRUN()
*
* Calls checkrunning(), checkchanged(), makefullname(),
* callscript(), MRUN210B\main()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to File.New_MailRun menu selection. Creates a
* new mailrun.
*
*********************************************************************
#endcomment
#ifndef MRUN210G
proc filenewmrun
#ifndef MRUN210B
string changesettings
#endif
if checkrunning() && checkchanged()
FLAGS = NEW
#ifndef MRUN210B
changesettings = makefullname(MailRunDir, "MRUN210B")
callscript(changesettings)
#else
main()
#endif
endif
endproc
#endif
#comment
*********************************************************************
*
* FILESAVE()
*
* Calls makefullname()
*
* Called by:
* MRUN210H: parsemenu(), makemrn(), changemailrun(), fileexit()
* MRUN210B: newmailrun()
*
* Corresponds to the File.Save menu selection. Saves the
* current mailrun.
*
*********************************************************************
#endcomment
proc filesave
string LastRun
if !(FLAGS & DEFAULTS)
findfirst MailRun
LastRun = makefullname(MailRunDir, $FILENAME)
if not NULLSTR $FILENAME
delfile LastRun
endif
copyfile MailRun LastRun
profilewr MailRunIni "MailRun" "MailRun" $FILENAME
endif
endproc
#comment
*********************************************************************
*
* FILESAVEAS()
*
* Calls fverify(), makefullname(), copymrn(), makemailrunlist()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the File.Save_AS menu selection. Saves the
* current mailrun under a new name and makes the new mailrun
* current.
*
*********************************************************************
#endcomment
#ifdef MRUN210A
proc filesaveas
string NewRun, temp
integer Response
;Make sure the entered MailRun ID is the correct length
;and that it doesn't already exist
while 1
NewRun = ""
sdlginput "New MailRun" \
"Save the current mailrun as:" NewRun
if FAILURE
exit
endif
strlwr NewRun
if not fverify(NewRun)
usermsg \
"A mailrun ID must be a valid DOS file name without the extension."
loopwhile
endif
strfmt temp "%s.mrn" NewRun
NewRun = makefullname(MailRunDir, temp)
if isfile NewRun
sdlgmsgbox "MailRun Message" \
"%s already exists!`r`n`r`nReplace it?" QUESTION YESNO Response 2
if Response == 7
;if user selected "No"
NewRun = ""
loopwhile
endif
endif
exitwhile
endwhile
delfile NewRun
MailRunTrunc = temp
copyfile MailRun NewRun
copymrn()
makemailrunlist()
updatedlg 512
endproc
#endif
#comment
*********************************************************************
*
* FILERESET()
*
* Calls maketasklist(), getfirstitem(), readbbs(), readitem(),
* writeitem()
*
* Called by:
* MRUN210H: parsemenu(), parseobject(), filereset()
*
* Corresponds to the File.Reset_MailRun menu selection.
* Resets completed permenant items to pending. Deletes
* completed temporary items.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc filereset
string Pending, Perm
integer p1, p2, i, j, k
i = 1
BBS = readbbs(i)
;Loop through each BBS
while not NULLSTR BBS
j = 1
k = 1
Item = readitem(j)
;Loop through each Item
while not NULLSTR Item
;Clear the old item
writeitem(j, "")
strextract pending Item "," 0
strextract perm Item "," 1
atoi pending p1
atoi perm p2
;Items that are completed and temporary will not be updated
;The second counter "k" is required to avoid gaps where items
;are deleted.
if (p1 != 0) || (p2 != 0)
strupdt Item "1" 0 1
writeitem(k, Item)
k++
endif
j++
Item = readitem(j)
endwhile
i++
BBS = readbbs(i)
endwhile
maketasklist()
getfirstitem()
updatedlg 80
endproc
#endif
#comment
*********************************************************************
*
* FILEDELMRUN()
*
* Calls makefullname(), copymrn(), makemailrunlist(),
* maketasklist(), getfirstitem()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the File.Delete_MailRun menu selection.
* Deletes the current mailrun and makes the next available
* mailrun current.
*
*********************************************************************
#endcomment
#ifdef MRUN210A
proc filedelmrun
string LastMRun
findfirst MailRun
LastMRun = makefullname(MailRunDir, $FILENAME)
delfile LastMRun
LastMRun = makefullname(MailRunDir, "*.MRN")
findfirst LastMRun
MailRunTrunc = $FILENAME
copymrn()
makemailrunlist()
maketasklist()
getfirstitem()
updatedlg -1
endproc
#endif
#comment
*********************************************************************
*
* FILEAUTORUN()
*
* Calls makefullname(), openfile()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the File.Create_AutoRun menu selection.
* Creates an AutoRun script file.
*
*********************************************************************
#endcomment
#ifndef MRUN210G
proc fileautorun
string AutoRunFile
findfirst MailRun
AutoRunFile = makefullname(MailRunDir, $FNAME)
strcat AutoRunFile ".WAS"
openfile(0, AutoRunFile, _CREATE, _TEXT)
fstrfmt 0 ";MailRun autostart script for %s`r`n`r`n" MailRunTrunc
fputs 0 "proc main"
fputs 0 "string MailRunIni"
fputs 0 "`tMailRunIni = $WINPATH"
fputs 0 "`taddfilename MailRunIni `"MAILRUN.INI`""
fputs 0 "`tprofilewr MailRunIni `"MailRun`" `"AutoRun`" 1"
fstrfmt 0 "`tprofilewr MailRunIni `"MailRun`" `"MailRun`" `"%s`"`r`n" \
MailRunTrunc
fputs 0 "`tchain `"MRUN210`""
fputs 0 "endproc"
fclose 0
endproc
#endif
#comment
*********************************************************************
*
* FILEEXIT()
*
* Calls filesave(), cleardir(), makefullname()
*
* Called by:
* MRUN210H: parsemenu(), parseobject(), openfile()
* MRUN210A: executor()
* MRUN210B: changemrundir()
* MRUN210G: dobbs()
*
* Corresponds to the File.Exit menu selection. Restores
* system settings, deletes temporary files, and halts script.
*
*********************************************************************
#endcomment
proc fileexit
string StateCapPath, StateCapFile, StateDnldPath, StateUpldPath
string CleanupFile
integer StateAutoDL, StateActionBar, StateMetaKeys
;Update the last mailrun
filesave()
;Retrieve the previous system state from the cleanup file
cleanupfile = makefullname(TempDir, "CLEANUP.TMP")
profilerd CleanupFile "Cleanup" "StateAutoDL" StateAutoDL
profilerd CleanupFile "Cleanup" "StateCapPath" StateCapPath
profilerd CleanupFile "Cleanup" "StateCapFile" StateCapFile
profilerd CleanupFile "Cleanup" "StateDnldPath" StateDnldPath
profilerd CleanupFile "Cleanup" "StateUpldPath" StateUpldPath
profilerd CleanupFile "Cleanup" "StateActionBar" StateActionBar
profilerd CleanupFile "Cleanup" "StateMetaKeys" StateMetaKeys
;Restore the settings
capture OFF
set capture path StateCapPath
set capture file StateCapFile
set dnldpath StateDnldPath
set upldpath StateUpldPath
set aspect rangechk ON
if StateAutoDL != 0
set autodnld ON
endif
if StateActionBar != 0
actionbar ON
endif
if StateMetaKeys != 0
metakeys ON
endif
cleardir(TempDir)
chdir MailRunDir
rmdir TempDir
statmsg ""
remove USERWIN
#ifdef MRUN210A
if PostRun == 3
closepw
endif
#endif
halt
endproc
#comment
*********************************************************************
*
* EDITCUT()
*
* Calls editcopy(), editdelete()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the Edit.Cut menu selection. Copies the
* current item in the Task List to the clipboard and deletes
* it from the Task List.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc editcut
editcopy()
editdelete()
endproc
#endif
#comment
*********************************************************************
*
* EDITCOPY()
*
* Calls getbbsi(), getitemi(), makefullname(), loadbbsinfo(),
* loadprompts(), loadmaildoor(), writebbsinfo(), writeprompts(),
* writemaildoor(), readitem()
*
* Called by:
* MRUN210H: parsemenu(), editcut()
*
* Coresponds to the Edit.Copy menu selection. Copies the
* currently selected item in the Task List to the clipboard.
* If the item is a BBS, all user info and prompts are copied
* as well.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc editcopy
string LastBBS, LastItem, LastMRun, temp
integer i, j
if NULLSTR TaskItem
return
endif
LastBBS = BBS
LastItem = Item
LastMRun = MailRun
i = getbbsi()
j = getitemi()
temp = makefullname(TempDir, "TEMP.TMP")
;If the current TaskItem is a BBS...
if j == 0
#ifdef MRUN210G
usermsg "Cannot copy/cut a BBS while a mailrun is executing!"
#else
loadbbsinfo()
loadprompts()
loadmaildoor()
MailRun = temp
profilewr temp "MailRun Data" "BBS" BBS
writebbsinfo()
writeprompts()
writemaildoor()
filetoclip TEXT temp
#endif
else
Item = readitem(j)
profilewr temp "MailRun Data" "Item" Item
filetoclip TEXT temp
endif
delfile temp
MailRun = LastMRun
BBS = LastBBS
Item = LastItem
endproc
#endif
#comment
*********************************************************************
*
* EDITPASTE()
*
* Calls getbbsi(), getitemi(), makefullname(), gettaskstring(),
* insertitem(), makebbslist(), insertbbs(), loadbbsinfo(),
* loadprompts(), loadmaildoor(), writebbsinfo(), writeprompts(),
* writemaildoor(), maketasklist()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the Edit.Paste menu selection. Pastes an
* item from the clipboard into the current mailrun.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc editpaste
string LastBBS, LastItem, LastMRun, temp
string NewBBS, NovumItem
integer i, j
LastMRun = MailRun
LastBBS = BBS
LastItem = Item
i = getbbsi()
j = getitemi()
temp = makefullname(TempDir, "TEMP.TMP")
cliptofile TEXT temp
profilerd temp "MailRun Data" "Item" NovumItem
profilerd temp "MailRun Data" "BBS" NewBBS
if not NULLSTR NovumItem
if NULLSTR TaskItem
usermsg "You must add a BBS first!"
return
endif
insertitem(j, NovumItem)
TaskItem = gettaskstring(i, j)
elseif not NULLSTR NewBBS
#ifdef MRUN210G
usermsg "Cannot paste a BBS while a mailrun is executing!"
#else
makebbslist()
if strfind BBSList NewBBS
errormsg "That BBS is already in the MailRun!"
return
endif
if not NULLSTR BBSList
insertbbs(i, NewBBS)
else
i = 0
profilewr MailRun "MailRun" "BBS_1" NewBBS
endif
BBS = NewBBS
MailRun = temp
loadbbsinfo()
loadprompts()
loadmaildoor()
MailRun = LastMRun
writebbsinfo()
writeprompts()
writemaildoor()
i++
strfmt TaskItem "%s`t`t`t%d`t0" BBSName i
#endif
else
usermsg "Nothing to paste!"
return
endif
BBS = LastBBS
Item = LastItem
maketasklist()
updatedlg 80
endproc
#endif
#comment
*********************************************************************
*
* EDITDELETE()
*
* Calls getbbsi(), getitemi(), readbbs(), readitem(),
* writebbs(), writeitem(), maketasklist(), makebbslist(),
* gettaskstring()
*
* Called by:
* MRUN210H: parsemenu(), parseobject(), editcut()
* MRUN210A: parsekeystate()
*
* Corresponds to the Edit.Delete menu selection. Deletes
* the currently selected item in the Task List.
*
*********************************************************************
#endcomment
#ifdef MRUN210AG
proc editdelete
string BBSNamen, LastBBS, LastItem
integer i, j, k, l
LastBBS = BBS
LastItem = Item
i = getbbsi()
j = getitemi()
if j == 0
;If the current TaskItem is a BBS...
l = i
k = l + 1
BBS = readbbs(k)
;Decrement the BBS coordinate of each BBS after the one selected
while not NULLSTR BBS
writebbs(l, BBS)
l++
k++
BBS = readbbs(k)
endwhile
writebbs(l, "")
;Update the task list
maketasklist()
;Reset the TaskItem. If the selected BBS was the last one
;in the list, set TaskItem to the previous BBS; otherwise,
;set it to the next BBS
BBS = readbbs(i)
if NULLSTR BBS
i--
BBS = readbbs(i)
if NULLSTR BBS
TaskItem = ""
else
profilerd MailRun BBS "BBSName" BBSNamen
strfmt TaskItem "%s`t`t`t%d`t%d" BBSNamen i 0
endif
else
profilerd MailRun BBS "BBSName" BBSNamen
strfmt TaskItem "%s`t`t`t%d`t%d" BBSNamen i 0
endif
else
;If the current TaskItem is an Item
l = j
k = l + 1
;Decrement the Item coordinate of each item after the one selected
Item = readitem(k)
while not NULLSTR Item
writeitem(l, Item)
l++
k++
Item = readitem(k)
endwhile
writeitem(l, "")
;Update the task list
maketasklist()
;Reset the TaskItem to the next Item for that BBS. If the selected
;Item was the last one for that BBS, set TaskItem to the previous
;Item. If it was the only item for that BBS, set it to the BBS name.
BBS = readbbs(i)
Item = readitem(j)
if not NULLSTR Item
;If it wasn't the last item...
TaskItem = gettaskstring(i, j)
elseif j == 1
;If it was the only item...
profilerd MailRun BBS "BBSName" BBSNamen
strfmt TaskItem "%s`t`t`t%d`t%d" BBSNamen i 0
else
;If it was the last of multiple items...
j--
Item = readitem(j)
TaskItem = gettaskstring(i, j)
endif
endif
if FLAGS & RUNNING
BBS = LastBBS
Item = LastItem
endif
updatedlg 80
endproc
#endif
#comment
*********************************************************************
*
* CFGMRUN()
*
* Calls checkchanged(), configmrun()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the Configure.MailRun_Settings menu selection.
*
*********************************************************************
#endcomment
proc cfgmrun
if checkchanged()
;reset all flags except RUNNING
FLAGS &= RUNNING
configmrun()
endif
endproc
#comment
*********************************************************************
*
* DEFAULTSMAILRUN()
*
* Calls checkchanged(), configmrun()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the Configure.Defaults.MailRun menu selection.
*
*********************************************************************
#endcomment
proc defaultsmailrun
#ifdef MRUN210B
if FLAGS & DEFAULTS
return
endif
#endif
if checkchanged()
;reset all flags but RUNNING and set the DEFAULTS flag
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configmrun()
endif
endproc
#comment
*********************************************************************
*
* CONFIGMRUN()
*
* Calls MRUN210B\main(), makefullname(), callscript()
*
* Called by:
* MRUN210H: cfgmrun(), defaultsmailrun()
*
* Calls the changesettings script module.
*
*********************************************************************
#endcomment
proc configmrun
#ifdef MRUN210B
main()
#else
string changesettings
changesettings = makefullname(MailRunDir, "MRUN210B")
callscript(changesettings)
#endif
endproc
#comment
*********************************************************************
*
* CFGBBS()
*
* Calls checkchanged(), checknew(), configbbs()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
* MRUN210C: changeprompts(), changemaildoor()
*
* Corresponds to the Configure.BBS_Settings menu selection.
*
*********************************************************************
#endcomment
proc cfgbbs
if checkchanged() && checknew()
FLAGS &= RUNNING
configbbs()
endif
endproc
#comment
*********************************************************************
*
* DEFAULTSBBS()
*
* Calls checkchanged(), configbbs()
*
* Called by:
* MRUN210H: parsemenu()
* MRUN210C: changeprompts(), changemaildoor()
*
* Corresponds to the Configure.Defaults.BBS menu selection.
*
*********************************************************************
#endcomment
proc defaultsbbs
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configbbs()
endif
endproc
#comment
*********************************************************************
*
* CONFIGBBS()
*
* Calls makefullname(), callscript(), changeuserinfo()
*
* Called by:
* MRUN210H: cfgbbs(), defaultsbbs()
*
* Calls the changebbs script module for the changeuserinfo()
* procedure.
*
*********************************************************************
#endcomment
proc configbbs
#ifndef MRUN210C
string changebbs
FLAGS = (FLAGS & CLEARCMD) | USR
changebbs = makefullname(MailRunDir, "MRUN210C")
callscript(changebbs)
#else
changeuserinfo()
#endif
endproc
#comment
*********************************************************************
*
* CFGPROMPTS()
*
* Calls checkchanged(), checknew(), configprompts
*
* Called by:
* MRUN210H: parsemenu()
* MRUN210C: changeuserinfo(), changemaildoor()
*
* Corresponds to the Configure.BBS_Prompts menu settings.
*
*********************************************************************
#endcomment
proc cfgprompts
if checkchanged() && checknew()
FLAGS &= RUNNING
configprompts()
endif
endproc
#comment
*********************************************************************
*
* DEFAULTSPROMPTS()
*
* Calls checkchanged(), configprompts()
*
* Called by:
* MRUN210H: parsemenu()
* MRUN210C: changeuserinfo(), changemaildoor()
*
* Corresponds to the Configure.Defaults.Prompts menu selection.
*
*********************************************************************
#endcomment
proc defaultsprompts
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configprompts()
endif
endproc
#comment
*********************************************************************
*
* CONFIGPROMPTS()
*
* Calls makefullname(), callscript(), changeprompts()
*
* Called by:
* MRUN210H: cfgprompts(), defaultsprompts()
*
* Calls the changebbs script module for the changeprompts()
* procedure.
*
*********************************************************************
#endcomment
proc configprompts
#ifndef MRUN210C
string changebbs
FLAGS = (FLAGS & CLEARCMD) | PRMPT
changebbs = makefullname(MailRunDir, "MRUN210C")
callscript(changebbs)
#else
changeprompts()
#endif
endproc
#comment
*********************************************************************
*
* CFGMAILDOOR()
*
* Calls checkchanged(), checknew(), configmaildoor()
*
* Called by:
* MRUN210H: parsemenu()
* MRUN210C: changeuserinfo(), changeprompts()
*
* Corresponds to the Configure.BBS_Mail_Door menu selection.
*
*********************************************************************
#endcomment
proc cfgmaildoor
if checkchanged() && checknew()
FLAGS &= RUNNING
configmaildoor()
endif
endproc
#comment
*********************************************************************
*
* DEFAULTSDOOR()
*
* Calls checkchanged(), configmaildoor()
*
* Called by:
* MRUN210H: parsemenu()
* MRUN210C: changeuserinfo(), changeprompts()
*
* Corresponds to the Configure.Defaults.Mail_Door menu selection.
*
*********************************************************************
#endcomment
proc defaultsdoor
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configmaildoor()
endif
endproc
#comment
*********************************************************************
*
* CONFIGMAILDOOR()
*
* Calls makefullname(), callscript(), changemaildoor()
*
* Called by:
* MRUN210H: cfgmaildoor(), defaultsmaildoor()
*
* Calls the changebbs script module for the changemaildoor()
* procedure.
*
*********************************************************************
#endcomment
proc configmaildoor
#ifndef MRUN210C
string changebbs
FLAGS = (FLAGS & CLEARCMD) | QMD
changebbs = makefullname(MailRunDir, "MRUN210C")
callscript(changebbs)
#else
changemaildoor()
#endif
endproc
#comment
*********************************************************************
*
* ADDNEWBBS()
*
* Calls checkchanged(), makefullname(), callscript()
* MRUN210C\changeuserinfo()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Add.New_BBS menu selection. Calls the
* changebbs module for the changeuserinfo() procedure with
* the NEW flag set.
*
*********************************************************************
#endcomment
proc addnewbbs
#ifndef MRUN210C
string changebbs
#endif
if checkchanged()
FLAGS &= RUNNING
FLAGS |= NEW
#ifndef MRUN210C
FLAGS = (FLAGS & CLEARCMD) | USR
changebbs = makefullname(MailRunDir, "MRUN210C")
callscript(changebbs)
#else
changeuserinfo()
#endif
endif
endproc
#comment
*********************************************************************
*
* ADDGETSEND()
*
* Calls checkchanged(), checknew(), makefullname(), callscript()
* MRUN210F\addgetmail()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Add.Get/Send_Mail menu selection. Calls
* the othercmds script module for the addgetmail() procedure.
*
*********************************************************************
#endcomment
proc addgetsend
#ifndef MRUN210F
string othercmds
#endif
if checkchanged() && checknew()
FLAGS &= RUNNING
#ifndef MRUN210F
FLAGS = (FLAGS & CLEARCMD) | AGM
othercmds = makefullname(MailRunDir, "MRUN210F")
callscript(othercmds)
#else
addgetmail()
#endif
endif
endproc
#comment
*********************************************************************
*
* ADDDOWNLOAD()
*
* Calls checkchanged(), checknew(), makefullname(), callscript()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Add.Download_File menu selection. Calls
* the adddlfile script module.
*
*********************************************************************
#endcomment
proc adddownload
#ifndef MRUN210D
string adddlfile
if checkchanged() && checknew()
FLAGS &= RUNNING
adddlfile = makefullname(MailRunDir, "MRUN210D")
callscript(adddlfile)
endif
#endif
endproc
#comment
*********************************************************************
*
* ADDUPLOAD()
*
* Calls checkchanged(), checknew(), makefullname(), callscript()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Add.Upload_File menu selection. Calls
* the addulfile script module.
*
*********************************************************************
#endcomment
proc addupload
#ifndef MRUN210E
string addulfile
if checkchanged() && checknew()
FLAGS &= RUNNING
addulfile = makefullname(MailRunDir, "MRUN210E")
callscript(addulfile)
endif
#endif
endproc
#comment
*********************************************************************
*
* ADDSENDCMD()
*
* Calls checkchanged(), checknew(), makefullname(), callscript(),
* MRUN210F\addsendcommand()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Add.Send_Command menu selection. Calls
* the othercmds script module for the addsendcommand() procedure.
*
*********************************************************************
#endcomment
proc addsendcmd
#ifndef MRUN210F
string othercmds
#endif
if checkchanged() && checknew()
FLAGS &= RUNNING
#ifndef MRUN210F
FLAGS = (FLAGS & CLEARCMD) | CMD
othercmds = makefullname(MailRunDir, "MRUN210F")
callscript(othercmds)
#else
addsendcommand()
#endif
endif
endproc
#comment
*********************************************************************
*
* ADDSCRIPT()
*
* Calls checkchanged(), checknew(), makefullname(), callscript(),
* MRUN210F\adddoscript()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Add.Execute_Script menu selection. Calls
* the othercmds script module for the adddoscript() procedure.
*
*********************************************************************
#endcomment
proc addscript
#ifndef MRUN210F
string othercmds
#endif
if checkchanged() && checknew()
FLAGS &= RUNNING
#ifndef MRUN210F
FLAGS = (FLAGS & CLEARCMD) | SCR
othercmds = makefullname(MailRunDir, "MRUN210F")
callscript(othercmds)
#else
adddoscript()
#endif
endif
endproc
#comment
*********************************************************************
*
* EXECUTEMAILRUN()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Execute.Execute/Terminate_MailRun menu
* selection.
*
*********************************************************************
#endcomment
proc executemailrun
#ifdef MRUN210G
hangup
FLAGS &= IDLE
capture OFF
exit
#else
if FLAGS & RUNNING
FLAGS &= IDLE
else
FLAGS |= RUNNING
endif
#endif
endproc
#comment
*********************************************************************
*
* EXECUTEARCHIVER()
*
* Calls checktask()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Execute.Archiver menu selection. Calls
* the archive utility specified in the MailRun Settings
* dialog.
*
*********************************************************************
#endcomment
proc executearchiver
integer i
#ifndef MRUN210AB
string Archiver
#endif
profilerd MailRun "MailRun" "Archiver" Archiver
if not NULLSTR Archiver
i = checktask(Archiver)
if i
activatetask i
else
run Archiver
endif
if FAILURE
usermsg "Unable to run Archive Utility %s .`r`n\
The file does not exist or is not in your DOS path." Archiver
endif
else
usermsg "You must specify an Archive Utility in`r`n\
the MailRun Settings dialog box."
endif
endproc
#comment
*********************************************************************
*
* EXECUTEQWKREADER()
*
* Calls checktask()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Execute.QWK_Reader menu selection. Calls
* the QWK mail reader specified in the MailRun Settings
* dialog.
*
*********************************************************************
#endcomment
proc executeqwkreader
integer i
#ifndef MRUN210AB
string QWKReader
#endif
profilerd MailRun "MailRun" "QWKReader" QWKReader
if not NULLSTR QWKReader
i = checktask(QWKReader)
if i
activatetask i
else
run QWKReader
endif
if FAILURE
usermsg "Unable to run QWK Mail Reader %s.`r`n\
The file does not exist or is not in your DOS path." QWKReader
endif
else
usermsg "You must specify a QWK Mail Reader in`r`n\
the MailRun Settings dialog box."
endif
endproc
#comment
*********************************************************************
*
* EXECUTELOGVIEWER()
*
* Calls checktask(), makefullname()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Execute.View_Log_File menu selection.
* Calls the file viewer specified in the MailRun Settings
* dialog and loads the log file for the current mailrun.
*
*********************************************************************
#endcomment
proc executelogviewer
string CapFile, RunLine, WinTitle
integer i, j
#ifndef MRUN210AB
string LogViewer
#endif
profilerd MailRun "MailRun" "LogViewer" LogViewer
if not NULLSTR LogViewer
if not NULLSTR MailRunTrunc
CapFile = makefullname(MailRunDir, MailRunTrunc)
strlwr CapFile
strreplace CapFile ".mrn" ".cap"
else
CapFile = ""
endif
i = checktask(LogViewer)
if i
taskwin i j
getwintext j WinTitle
if strfind WinTitle CapFile
activatetask i
return
endif
endif
strfmt RunLine "%s %s" LogViewer CapFile
run RunLine
if FAILURE
usermsg "Unable to run Log File Viewer %s.`r`n\
The file does not exist or is not in your DOS path." LogViewer
endif
else
usermsg "You must specify a Log File Viewer in`r`n\
the MailRun Settings dialog box."
endif
endproc
#comment
*********************************************************************
*
* HELPCONTENTS()
*
* Called by:
* MRUN210H: parsemenu()
*
* Corresponds to the Help.Contents menu selection. Calls
* the help file and displays the contents page.
*
*********************************************************************
#endcomment
proc helpcontents
help 1
endproc
#comment
*********************************************************************
*
* HELPCONTEXT()
*
* Called by:
* MRUN210H: parsemenu(), parseobject()
*
* Corresponds to the Help.On_current_window menu selection.
* Calls the help file and displays the page appropriate for
* the current dialog box. HelpPage is a global variable set
* in each procedure that calls a dialog box.
*
*********************************************************************
#endcomment
proc helpcontext
help HelpPage
endproc
#comment
*********************************************************************
*
* HELPABOUT()
*
* Calls checkchanged(), makefullname(), callscript(),
* MRUN210F\showabout()
*
* Called by:
* MRUN210H: parsemenu()
* MRUN210A: main()
*
* Corresponds to the Help.About_MailRun menu selection. Calls
* the othercmds script module for the showabout() procedure.
*
*********************************************************************
#endcomment
proc helpabout
#ifndef MRUN210F
string othercmds
#endif
if checkchanged()
FLAGS &= RUNNING
#ifndef MRUN210F
FLAGS = (FLAGS & CLEARCMD) | ABT
othercmds = makefullname(MailRunDir, "MRUN210F")
callscript(othercmds)
#else
showabout()
#endif
endif
endproc
#comment
*********************************************************************
*
* CALLSCRIPT()
*
* Calls menudim(), makemailrunlist(), makebbslist(),
* maketasklist(), getfirstitem(), MRUN210AG\mailrunbox()
*
* Called by:
* MRUN210H: filenewmrun(), configmrun(), configbbs(),
* configprompts(), configmaildoor(), addnewbbs(),
* addgetsend(), adddownload(), addupload(),
* addsendcmd(), addscript(), helpabout()
*
* Executes the specified MailRun script module.
*
*********************************************************************
#endcomment
proc callscript
strparm ScriptTitle
#ifndef MRUN210AG
chain ScriptTitle
#else
string LastMRun
LastMRun = MailRun
execute ScriptTitle
menudim()
FLAGS &= RUNNING
#ifdef MRUN210G
if !(FLAGS & RUNNING)
;if the mailrun has been terminated from another script module...
executemailrun()
endif
profilerd MailRun "MailRun" "LogRun" LogRun
if LogRun
profilerd MailRun "MailRun" "AnsiInLog" AnsiInLog
if AnsiInLog
set capture mode append RAW
else
set capture mode append VISUAL
endif
capture ON
else
capture OFF
endif
#else
findfirst MailRun
MailRunTrunc = $FILENAME
makemailrunlist()
makebbslist()
#endif
maketasklist()
if not strcmpi LastMRun MailRun
getfirstitem()
endif
mailrunbox()
statmsg ""
#endif
endproc